///*
// * Copyright 2008 Jeffrey R Griffin.
// */
//
//package net.visibleblue.xstream;
//
//import java.net.URISyntaxException;
//
//import android.content.ComponentName;
//import android.content.Intent;
//import android.net.ContentURI;
//import android.os.Bundle;
//
//import com.thoughtworks.xstream.converters.Converter;
//import com.thoughtworks.xstream.converters.MarshallingContext;
//import com.thoughtworks.xstream.converters.UnmarshallingContext;
//import com.thoughtworks.xstream.io.HierarchicalStreamReader;
//import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
//
//public class IntentConverter implements Converter {
//
//	@Override
//	public void marshal(Object arg0, HierarchicalStreamWriter arg1,
//			MarshallingContext arg2) {
//		Intent intent = (Intent)arg0;
//		if(intent.getAction()!=null)
//			arg1.addAttribute("action", intent.getAction());
//		if(intent.getScheme()!=null)
//			arg1.addAttribute("scheme", intent.getScheme());
//		if(intent.getType()!=null)
//			arg1.addAttribute("mime-type", intent.getType());
//		if(intent.getData()!=null)
//			arg1.addAttribute("data", intent.getData().toString());
//		if(intent.getComponent()!=null)
//			arg1.addAttribute("component", intent.getComponent().flattenToString());
//		if(intent.getExtras()!=null && !intent.getExtras().isEmpty())
//		{
//			arg1.startNode("extras");
//			arg2.convertAnother(intent.getExtras());
//			arg1.endNode();
//		}
//	}
//
//	@Override
//	public Object unmarshal(HierarchicalStreamReader arg0,
//			UnmarshallingContext arg1) {
//		Intent intent = new Intent();
//		intent.setAction(arg0.getAttribute("action"));
//		intent.setType(arg0.getAttribute("scheme"));
//		intent.setType(arg0.getAttribute("mime-type"));
//		try
//		{
//			intent.setData(new ContentURI(arg0.getAttribute("data")));
//		}
//		catch(URISyntaxException uriEx)
//		{
//			throw new RuntimeException(uriEx);
//		}
//		String comp = arg0.getAttribute("component");
//		if(comp!=null)
//			intent.setComponent(ComponentName.unflattenFromString(comp));
//		while(arg0.hasMoreChildren())
//		{
//			String name = arg0.getNodeName();
//			if(name.equals("extras"))
//			{
//				arg0.moveDown();
//				intent.putExtras((Bundle)arg1.convertAnother(intent, 
//						Bundle.class));
//				arg0.moveUp();
//			}
//		}
//		return intent;
//	}
//
//	@Override
//	public boolean canConvert(Class arg0) {
//		return arg0.equals(Intent.class);
//	}
//
//}
